<template>
  <el-config-provider :locale="state.locale">
    <router-view v-if="state.isRouterActive" />
  </el-config-provider>
</template>

<script setup lang="ts">
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import useMqtt from '@/utils/useMqtt'
const { startMqtt } = useMqtt()
const { proxy }:any = getCurrentInstance()
const publicStore = proxy.publicStore()
const configStore = proxy.configStore()
const state = reactive({
	...configStore.$state,
	...publicStore.$state,
	locale: zhCn,
	isRouterActive: true,
})

provide('reload', () => {
	state.isRouterActive = false
	nextTick(() => {
		state.isRouterActive = true
	})
})

if(configStore.isMqtt){
  startMqtt('/event/client/#', (topic, message) => {
    const msg = JSON.parse(message.toString());
    console.log('mqtt--', msg)
  })
}
</script>

<style lang="scss" scoped>

</style>
